package com.xiaohei.rabbitmq.utils;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;


/**
 * @Description:
 * @Author: 王希辰
 * @Date: 2022/3/16 16:23
 */
public class RabbitmqUtils {
    public static Channel getChannel() throws Exception{
        //创建一个连接工厂
        ConnectionFactory factory=new com.rabbitmq.client.ConnectionFactory();
        //工厂IP 连接rabbitmq的队列
        factory.setHost("192.168.80.44");
        //用户名
        factory.setUsername("admin");
        //密码
        factory.setPassword("admin");
        //创建连接
        Connection connection = factory.newConnection();
        //获取信道
        return connection.createChannel();
    }
}
